package com.book.controller;

import cn.hutool.core.lang.Snowflake;
import com.book.entity.BookUserAddress;
import com.book.service.BookUserAddressService;
import com.book.util.JsonResult;
import com.book.vo.AddressVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author SuperYu  2024/7/30
 */

@Controller
@RequestMapping("/address")
@Slf4j
public class BookUserAddressController {
    @Resource
    BookUserAddressService bookUserAddressService;


    @GetMapping("/findByUserId")
    @ResponseBody
    public JsonResult<List<AddressVo>> findByUserId(HttpSession session) {
        // 从数据库查出，当前用户的购物车数据
        Long userId = (Long) session.getAttribute("loginUserId");

        List<AddressVo> list = bookUserAddressService.findAddressByUserId(userId.intValue());

        return JsonResult.ok(200,list);
    }

}
